import React from 'react'
import { Input } from './control/Input'
import { Password } from './control/Password'
import { Submit } from './control/Submit'
import { Title } from './control/Title'
import { ImgVCode } from './control/ImgVCode'
import { VCode } from './control/VCode'
import { Row } from './control/Row'
import { Checkbox } from './control/Checkbox'
import Panel from './panel/base/index'
import BaseTheme from './theme/base'

import { AccountProvider } from './context'

type AccountProps<T extends React.ElementType> = {
  onSubmit: (formData:any) => Promise<any>
  Theme?: T
  children: React.ReactNode;
} & React.ComponentProps<T>; // 使用 React.ComponentProps 获取传入组件的 props

function Account<T  extends React.ElementType  = typeof BaseTheme>({ children,onSubmit,
  Theme = BaseTheme as T ,...rest}: AccountProps<T>) {
  //const AccountTheme = Theme?Theme:BaseTheme 
  return <AccountProvider onSubmit={onSubmit}>
    <Theme {...rest}>{children}</Theme>
  </AccountProvider> 
}

const Test= ()=><Account backgroundUrl='' onSubmit={function (): Promise<any> {
  throw new Error('Function not implemented.')
} } children={undefined}/>
Account.Input = Input
Account.Password = Password
Account.Submit = Submit
Account.Title = Title
Account.ImgVCode = ImgVCode
Account.VCode = VCode
Account.Checkbox = Checkbox
Account.Row = Row
Account.Panel = Panel
export default Account